//
//  LPVideoViewTableGGBClassIntroViewController.m
//  ZhongWangYuanApp
//
//  Created by liuyingping on 2018/6/4.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "LPVideoViewTableGGBClassIntroViewController.h"
#import "LPVideoViewTableGGBPlayListViewController.h"
#import "LPZWYChooseClassClassModel.h"
@interface LPVideoViewTableGGBClassIntroViewController ()
/**    */
@property (strong, nonatomic) UIScrollView  *backScollerView;
/**    */
@property (strong, nonatomic) UILabel  *contentLabel;

@end

@implementation LPVideoViewTableGGBClassIntroViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.view addSubview:self.backScollerView];
    [self.backScollerView addSubview:self.contentLabel];

    self.contentLabel.sd_layout
    .topSpaceToView(self.backScollerView, 15 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self.backScollerView, 20 * [UIScreen zj_screenWScale])
    .widthIs([UIScreen zj_screenWith] - 40 * [UIScreen zj_screenWScale] )
    .heightIs(10);
  
    [self.backScollerView setupAutoContentSizeWithBottomView:self.contentLabel bottomMargin:30 * [UIScreen zj_screenHScale]];
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getNewVideoID:) name:Notification_CourseComment object:nil];
    [self setupContentLabelFromText:self.model.content];
}

- (void)setupContentLabelFromText:(NSString *)text{
    self.contentLabel.keywordsColor = self.backScollerView.backgroundColor;
    self.contentLabel.text = [NSString stringWithFormat:@"尚錕%@",[NSString string:text isNilStringReturnDeftString:@"暂无简介" ]];
    self.contentLabel.sd_layout
    .topSpaceToView(self.backScollerView, 15 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self.backScollerView, 20 * [UIScreen zj_screenWScale])
    .widthIs([UIScreen zj_screenWith] - 40 * [UIScreen zj_screenWScale])
    .heightIs([self.contentLabel getLableSizeWithMaxWidth:self.contentLabel.width].height);
}

#pragma mark - 接受通知
- (void)getNewVideoID:(NSNotification *)Info{
    NSDictionary *dict = Info.object;
     LPZWYChooseClassClassModel * model = [dict objectForKey:@"Model"];
    if (model.comment) {
      [self setupContentLabelFromText:model.comment];
    }
    
}

- (void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

#pragma mark - getter
- (UIScrollView *)backScollerView{
    if (!_backScollerView ) {
        _backScollerView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, [UIScreen zj_screenHeight] - LP_NavViewHeight - 100 * [UIScreen zj_screenHScale] - [UIScreen zj_screenWith] / 16 * 9 - 47 * [UIScreen zj_screenHScale]- [NSString heightWithTextFont:LYPFONT(18)] - 1 )];
        _backScollerView.showsVerticalScrollIndicator = NO;
        _backScollerView.showsHorizontalScrollIndicator = NO;
        _backScollerView.contentSize = _backScollerView.size;
        _backScollerView.backgroundColor = [UIColor themeWhiteColor];
    }
    return _backScollerView;
    
}


- (UILabel *)contentLabel{
    if (_contentLabel == nil) {
        _contentLabel = [UILabel new];
        _contentLabel.textColor = [UIColor textGrayColor];
        _contentLabel.font = LYPFONT(16);
        _contentLabel.numberOfLines = 0;
        _contentLabel.characterSpace = 1;
        _contentLabel.lineSpace = 8 * [UIScreen zj_screenHScale];
        _contentLabel.keywordsArray = @[@"尚錕"];
        _contentLabel.keywordsFont = _contentLabel.font;
    }
    return _contentLabel;
}

@end
